<template>
    <BaseDialog
      title="审核"
      :handleCancel="handleCancel"
      :dialogVisible="props.dialogVisible"
    >
      <BaseForm
        labelWidth="100px"
        type="rule"
        :handleOk="handleOk"
        :handleCancel="handleCancel"
        :items="formItems"
        v-model:form="ruleForm"
        :rules="rules"
        :refresh="handleSearch"
      >
      </BaseForm>
    </BaseDialog>
  </template>
  
  <script setup lang="ts">
  import { contentManagementService } from '@/api/contentManagement'
  const props = defineProps({
    dialogVisible: {
      type: Boolean,
    },
    item: {
      type: Object,
    },
    handleSearch: {
      type: Function,
    },
    searchParams: { 
      type: Object,
    },
  })
  const ruleForm = ref({})
  const emit = defineEmits(['update:dialogVisible'])
  const formItems = ref([
    {
      name: '审核结果',
      key: 'auditStatus',
      type: 'radio',
      options: [
        {
          label: '通过',
          value: 2,
        },
        {
          label: '不通过',
          value: 3,
        },
      ],
    },
    {
      name: '备注',
      key: 'remark',
      type: 'textarea',
      maxlength: '500',
      'show-word-limit': true,
    },
  ])
  const rules = reactive({
    auditStatus: [{ required: true, message: '请选择', trigger: 'change' }],
  })
  
  const handleOk = () => {
    return contentManagementService.relationBatchAudit({
      data: {
        publishMessageUserRelationIds: props.item.map((e) => e.id),
        ...ruleForm.value,
      },
    })
  }
  const handleCancel = () => {
    emit('update:dialogVisible', false)
  }
  </script>
  
  <style lang="scss" scoped>
  :deep(.el-form-item__label) {
    justify-content: flex-end;
  }
  </style>
  